-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable no unchecked index access rule #6441
base: master
Are you sure you want to change the base?
Conversation
Cloudflare Pages deployment
|
Quality Gate passedIssues Measures |
if (ratings.length) { | ||
const lastRating = ratings[ratings.length - 1]; | ||
|
||
if (lastRating.Value === rating.Value) { | ||
if (lastRating && lastRating.Value === rating.Value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we have a rule to use an optional chain instead of foo && foo.bar
?
foo && foo.bar
is more portable though.
@@ -79,10 +79,12 @@ const UserParentalControl = () => { | |||
for (let i = 0, length = allParentalRatings.length; i < length; i++) { | |||
rating = allParentalRatings[i]; | |||
|
|||
if (!rating) continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we even get allParentalRatings
with null|undefined
elements?
I'm not a fan of checking everything (following some "pattern"), ignoring the fact that it will never happen. 🤷♂️ If this can happen, we silently ignore the invalid argument (the array with the invalid element), which can make it harder to find the error.
if (foundCard || !queue) { | ||
ids.push(items[i].Id); | ||
ids.push(items[i]?.Id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The optional chain is redundant - items[i]
is checked above. But again, can items
have invalid elements?
@@ -1,20 +1,20 @@ | |||
import type { MediaSegmentDto } from '@jellyfin/sdk/lib/generated-client/models/media-segment-dto'; | |||
|
|||
const isBeforeSegment = (segment: MediaSegmentDto, time: number, direction: number) => { | |||
const isBeforeSegment = (segment: MediaSegmentDto | undefined, time: number, direction: number) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would be better to force the caller to check that segment
is not "null", instead of putting optioal chains everywhere?
@@ -93,6 +93,8 @@ function getPosition(positionTo: Element, options: Options, dlg: HTMLElement) { | |||
|
|||
const pos = getOffsets([positionTo])[0]; | |||
|
|||
if (!pos) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only case (with [positionTo]
) where pos
will be invalid is if document
is not present. 😐
@@ -250,6 +252,8 @@ export function show(options: Options) { | |||
for (let i = 0; i < options.items.length; i++) { | |||
const item = options.items[i]; | |||
|
|||
if (!item) continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can happen?
If can - the error is shadowed.
Changes
Enables the no unchecked index access rule for typescript as recommended here and fixes the related errors
Issues
N/A